export default {
    data() {
        return {
            mixinUploadLoading: false,
            mixinMaxSize: 10240,
            mixinTemplateUrl: '/api/compete/topoTarget/excel-template',
            mixinUploadAction: '',
            mixinUploadHeader: {
                Authorization: localStorage.token,
                Accept: '*/*',
            },
            mixinFormat: ['xlsx'],
        };
    },
    mounted() {
        if (this.hwType === 0 || this.hwType === 3) {
            //老护网
            this.mixinTemplateUrl = '/api/compete/old/topoTarget/excel-template';
            this.mixinUploadAction = `/api/compete/old/topoTarget/projects/${this.$route.query.prjid}/input?testId=${this.$route.query.id}`;
        } else {
            this.mixinUploadAction = `/api/compete/topoTarget/projects/${this.$route.query.prjid}/input?testId=${this.$route.query.id}`;
        }
    },
    methods: {
        mixinHandleFormatError() {
            this.mixinUploadLoading = false;
            this.$Message.warning('文件格式错误，请上传xlsx格式');
            return false;
        },
        mixinBeforeUpload(file) {
            this.mixinUploadLoading = true;
            let name = file.name.split('.')[0];
            let reg = /^[0-9a-zA-Z_\u4e00-\u9fa5]*$/;
            if (!reg.test(name)) {
                this.mixinUploadLoading = false;
                this.$Message.warning('文件名只能包含数字，字母，汉字和下划线');
                return false;
            }
            if (name.length > 50) {
                this.mixinUploadLoading = false;
                this.$Message.warning('文件名的长度不能超过50个字符');
                return false;
            }
        },
        mixinFileHasExceed() {
            this.mixinUploadLoading = false;
            this.$Message.warning('请上传10M以内的文档');
            return false;
        },
    },
};
